package com.liu.project.pojo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @program: project
 * @description: 当前登录用户信息
 * @author: 86187
 * @create: 2022-03-01 15:43
 **/
@Data
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class LoginUser implements UserDetails {

    private Collection<SysRole> authorities;//角色配置类

    private int id;

    private String username;

    private String token;

    private String password;

    public LoginUser(Collection<SysRole> authorities, String token, String username, String password) {
        this.authorities = authorities;
        this.token=token;
        this.username = username;
        this.password = password;
    }

    @Override
    public Collection<SysRole> getAuthorities() {
        return this.authorities;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
